/**
 * route 系统模块：目录对应到模块，相当于子服务处理部分功能
 */
const express = require('express')

let server = express()
server.listen(8080)

// 目录一：user
let routerUser = express.Router() // 创建router
server.use('/user', routerUser) // 指定目录，配置相关模块
routerUser.get('/1.html', (req, res) => {
  res.send('user one')
})
routerUser.get('/2.html', (req, res) => {
  res.send('user two')
})

// 多层路由嵌套
// 目录二：article；路径：/article/1.html
let routerArticle = express.Router()
server.use('/article', routerArticle)
routerArticle.get('/1.html', (req, res) => {
  res.send('article one')
})
routerArticle.get('/2.html', (req, res) => {
  res.send('article two')
})
// 子路由；路径：/article/details/1.html
let routerDetails = express.Router()
routerArticle.use('/details', routerDetails)
routerDetails.get('/1.html', (req, res) => {
  res.send('details one')
})
